package com.zzc.service;

import com.zzc.bean.Employee;
import com.zzc.bean.SystemSet;
import com.zzc.dao.SystemSetDao;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SystemSetService {
	SystemSetDao systemSetDao;

	public SystemSetDao getSystemSetDao() {
		return systemSetDao;
	}

	public void setSystemSetDao(SystemSetDao systemSetDao) {
		this.systemSetDao = systemSetDao;
	}
	public SystemSet getSystemSet(){
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpSession session=request.getSession();
		Employee employee= (Employee) session.getAttribute("employee");
		SystemSet systemSet=systemSetDao.getSystemSet(employee.getEmployee_account());
		return systemSet;
	}

	public boolean setAdvance() {
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpSession session=request.getSession();
		Employee employee= (Employee) session.getAttribute("employee");
		String isAdvance_string=request.getParameter("isAdvance");
		boolean isAdvance= Boolean.parseBoolean(isAdvance_string);
		String advanceDining_time=request.getParameter("advanceDining_time");
		String signDate_time=request.getParameter("signDate_time");
		System.out.println("advanceDining_time:"+advanceDining_time);
		System.out.println("signDate_time:"+signDate_time);
		return systemSetDao.setAdvance(employee.getEmployee_account(),isAdvance,advanceDining_time,signDate_time);
    }
}
